package com.zy.batiya.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zy.batiya.domain.User;
import com.zy.batiya.mapper.UserMapper;
import com.zy.batiya.service.UserService;

@Component
@Transactional
public class UserServiceImpl implements UserService{
	
	@Autowired
	private UserMapper userMapper;
	
	@Override
	public User findByName(String name) throws Exception {
		// TODO Auto-generated method stub
		User user = null;
		List<User> users = userMapper.findByName(name);
		if(users!=null&&users.size()>0){
			user = users.get(0);
		}
		return user;
	}

	@Override
	public List<User> findAll() throws Exception {
		// TODO Auto-generated method stub
		return userMapper.findAll();
	}

	@Override
	public User findById(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return userMapper.findById(id);
	}

	@Override
	public Integer save(User user) throws Exception {
		// TODO Auto-generated method stub
		return userMapper.save(user);
	}

	@Override
	public void updateUser(User user) {
		// TODO Auto-generated method stub
		userMapper.updateUser(user);
	}

	@Override
	public void deleteById(Integer id) {
		// TODO Auto-generated method stub
		userMapper.deleteUserById(id);
	}

	@Override
	public List<User> getUsersByName(String userName, Integer start,
			Integer length, String columnName, String orderDir) {
		// TODO Auto-generated method stub
		return userMapper.getUsersByName(userName, start, length, columnName, orderDir);
	}

	@Override
	public Integer getUsersPageCountByName(String userName) {
		// TODO Auto-generated method stub
		return userMapper.getUsersPageCountByName(userName);
	}

	@Override
	public Integer verifyPassWord(String userName, String md5) {
		// TODO Auto-generated method stub
		return userMapper.verifyPassWord(userName, md5);
	}

	@Override
	public void updatePassWord(Integer id, String md5) {
		// TODO Auto-generated method stub
		userMapper.updatePassWord(id, md5);
	}

}
